{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>添加古建资料</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="build_name" lay-verify="required" placeholder="古建名称" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">缩略图：</label>
                <input type="hidden" name="build_thumb" id="lay-img" lay-verify="image">
                <div class="layui-input-block">
                    <div id="lay-upload">上传图片</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" id="lay-list">
                        </div>
                    </blockquote>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">年代：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="build_tag" lay-verify="required" placeholder="年代标签">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">工艺：</label>
                <div class="layui-input-block">
                    <input type="text" name="build_art" lay-verify="required" placeholder="工艺标签" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">类型：</label>
                <div class="layui-input-block">
                    <input type="text" name="build_type" lay-verify="required" placeholder="文件类型" class="layui-input ">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">摘要：</label>
                <div class="layui-input-block">
                    <textarea name="build_abstract" lay-verify="required" placeholder="文章摘要" class="layui-textarea" maxlength="40"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">音频：</label>
                <input type="hidden" name="build_music" id="lay-music" lay-verify="music">
                <div class="layui-input-block">
                    <div id="lay-music-upload">上传音频</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览音频：
                        <div class="layui-upload-list" id="lay-music-list">
                        </div>
                    </blockquote>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">zip文件：</label>
                <input type="hidden" name="build_zip" id="lay-zip" lay-verify="zip">
                <div class="layui-input-block">
                    <div id="lay-upload-zip">上传</div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览：
                        <div class="layui-upload-list" id="lay-zip-list">
                        </div>
                    </blockquote>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <label class="layui-form-label">音频名称：</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="music_name" lay-verify="required" placeholder="音频名称">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                <label class="layui-form-label">内容：</label>
                <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                    <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,url:"{:url('Upload/uploadLocality')}",domain:"{:http_type()}"});
    wk.uploadMusic({size:100,type:'mp3',url:"{:url('Upload/uploadLocality')}",domain:"{:http_type()}"});
    wk.uploadZip({size:100,type:'zip',url:"{:url('Upload/uploadLocality')}",domain:"{:http_type()}"});
    var editor = wk.wang({elem:'#LAY_editor'});
    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            image:[/\S/,'请上传图片'],
            music:[/\S/,'请上传音频'],
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            data.field.build_intro = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('guAdd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Info/guIndex')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>